<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>新增职位</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main- container">

                <!--职位名称-->
                <div class="layui-form-item">
                    <label class="layui-form-label">职位名称</label>
                    <div class="layui-input-block">
                        <input id="identity" type="text" name="identity" lay-verify="required" autocomplete="off"
                               placeholder="请输入职位名称"
                               class="layui-input" lay-reqText="请输入职位名称">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">职位描述</label>
                    <div class="layui-input-block">
                        <textarea id="description" name="description" required lay-verify="title"
                                  placeholder="这里输入对该职位的描述（选填）"
                                  class="layui-textarea" style="height: 210px"></textarea>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery', 'loading', 'laydate'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let loading = layui.loading;


        form.on('submit(user-save)', function (data) {
            //console.log(data.field);
            loading.Load(3, "");
            $.ajax({
                url: '/Identity/addIdentity',
                data: data.field,
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    loading.loadRemove();
                    console.log(result);
                    if (result.success == '1') {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            //console.log(JSON.stringify(result.data));
                            parent.layui.table.reload("user-table", {
                                data: result.data,
                                page: {
                                    layout: ['count', 'prev', 'page', 'next', 'skip']
                                    , curr: parent.layui.jquery(".layui-laypage-em").next().html()
                                    , groups: 3
                                    , last: false
                                }
                            });
                        });
                    } else {
                        layer.open({
                            title: '提示'
                            , icon: 2
                            , content: result.msg
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>